package com.yml.mybatis.gererator.util;

import java.io.File;

/**
 * @author YML
 * @since 2023-07-20 14:18
 */
public class StrUtils {

    public static String camelCase(String input, boolean firstUp) {
        String[] words = input.split("_");
        String first = words[0];
        if (firstUp) {
            String word = words[0];
            first = Character.toUpperCase(word.charAt(0)) + word.substring(1);
        }
        StringBuilder result = new StringBuilder(first);
        for (int i = 1; i < words.length; i++) {
            String word = words[i];
            String capitalizedWord = Character.toUpperCase(word.charAt(0)) + word.substring(1);
            result.append(capitalizedWord);
        }
        return result.toString();
    }

    public static String formatFilePath(String input) {
        return input.replace(".", "/");
    }

    public static String formatPackagePath(String input) {
        return input.replace(File.separator, ".").replace("/", ".");
    }
}
